package com.aep.provisioning.dao;

import java.util.List;

import com.aep.provisioning.domain.Contact;
import com.aep.provisioning.domain.Geography;
import com.aep.provisioning.util.Constants;

public class CommonDAOImpl extends BaseDAOHibernate implements CommonDAO{

	public void saveContact (Contact contact){
		super.save(contact);
	}
	public List<Geography> listDepartamentos(){
		Object[] params = {Constants.GO_DEPARTAMENTO};
		StringBuilder query = new StringBuilder();
		query.append("FROM Geography go ")
		.append("where go.geographyType=? ")
		.append("GROUP BY go.name ")
		.append("ORDER BY go.name ASC ");
		return super.find(Geography.class, query.toString(), params);
	}
	public List<Geography> listProvincias(Long idDepartamento){
		Object[] params = {Constants.GO_PROVINCIA,idDepartamento};
		StringBuilder query = new StringBuilder();
		query.append("FROM Geography go ")
		.append("where go.geographyType=? ")
		.append("and go.departamento=? ")
		.append("GROUP BY go.name ")
		.append("ORDER BY go.name ASC ");
		return super.find(Geography.class, query.toString(), params);
	}
	
}
